<template>
	<view class="main">
		<view>
			<button class="mini-btn" type="primary" size="mini" @click="handleMyDispath">我的派送任务</button>
			<!-- <button @click="start">Start GoogleMap</button> -->
		</view>
		<uni-table ref="table" :loading="loading" border stripe emptyText="暂无数据">
			<uni-tr>
				<uni-th align="center">批次名</uni-th>
				<uni-th align="center">状态</uni-th>
			</uni-tr>
			<uni-tr v-for="(item, index) in tableData" :key="index">
				<uni-td align="center">{{ item.name }}</uni-td>
				<uni-td>
					<view align="center">{{ item.status }}</view>
				</uni-td>
			</uni-tr>
		</uni-table>
		<view class="pagination-padding">
			<uni-pagination show-icon :page-size="queryParams.pageSize" :current="queryParams.pageNum" :total="total"
				@change="getList" />
		</view>
		<!-- 提示窗示例 -->
		<uni-popup ref="alertDialog" type="dialog">
			<uni-popup-dialog :type="'msgType'" cancelText="关闭" confirmText="同意" title="通知"
				content="欢迎使用 uni-popup!"></uni-popup-dialog>
		</uni-popup>
	</view>

	<!-- <button @click="start">Start GoogleMap</button> -->
</template>

<script>
	import {
		printShipments,
		googleRouteBatchList,
		deleteGoogleRouteBatch,
		startShipment,
	} from '@/api/orderManage/batchDispatch'
	import {
		myUnCompleteList
	} from '@/api/orderManage/myDispatch'

	export default {
		data() {
			return {
				/**表格数据 */
				tableData: [],
				/**数据总条数 */
				total: 0,
				/**表格加载状态 */
				loading: false,
				user: '',
				/**查询参数 */
				queryParams: {
					pageNum: 1,
					pageSize: 10,
				},
			}
		},
		methods: {
			handleMyDispath() {
				uni.reLaunch({
					url: '/pages/myDispatch/index'
				})
			},
			/** 查询列表 */
			getList() {
				this.loading = true
				googleRouteBatchList(this.queryParams)
					.then((res) => {
						this.tableData = res.rows
						this.total = res.total
					})
					.finally(() => (this.loading = false))
			},
			start() {
				uni.navigateTo({
					url: '/pages/map/map'
				})
			}
		},
		mounted() {
			this.getList()
		}
	}
</script>

<style scoped>
	.main {
		padding: 15rpx;
		width: 100%;
		height: 100vh;
		background: #fff;
	}

	.pagination-padding {
		margin: 10rpx 0;
	}
</style>